package com.liangzhong.model
{
	import com.liangzhong.model.FameHall.FameHallDateManager;
	import com.liangzhong.model.activity.ActivityDateManager;
	import com.liangzhong.model.bag.BagDataManager;
	import com.liangzhong.model.buffer.BufferManager;
	import com.liangzhong.model.chat.ChatDataManger;
	import com.liangzhong.model.club.ClubDataManager;
	import com.liangzhong.model.club.NpcClubDataManager;
	import com.liangzhong.model.compete.CompeteDataManager;
	import com.liangzhong.model.court.CourtDataManager;
	import com.liangzhong.model.explore.ExploreDataManager;
	import com.liangzhong.model.friend.FriendManager;
	import com.liangzhong.model.goldpalace.GoldPalaceDataManager;
	import com.liangzhong.model.goods.GoodsManager;
	import com.liangzhong.model.guide.GuideManager;
	import com.liangzhong.model.helper.HelperDateManger;
	import com.liangzhong.model.ladderMatch.LadderMatchDataManger;
	import com.liangzhong.model.leagueMatch.LeagueMatchDataManager;
	import com.liangzhong.model.lottery.LotteryDataManger;
	import com.liangzhong.model.mail.MailDataManager;
	import com.liangzhong.model.match.MatchDataManager;
	import com.liangzhong.model.match.MatchInfo;
	import com.liangzhong.model.playerCenter.PlayerCenterDataManager;
	import com.liangzhong.model.rankinglist.RankinglistDataManager;
	import com.liangzhong.model.shop.ShopDataManager;
	import com.liangzhong.model.stadium.stadiumDataManager.StadiumDataManager;
	import com.liangzhong.model.task.TaskManager;
	import com.liangzhong.model.techBar.TechBarDataManager;
	import com.liangzhong.model.tourMatch.TourMatchManager;
	import com.liangzhong.model.tradeCenter.TradeCenterManager;
	import com.liangzhong.model.trainingcamp.TrainingcampDataManager;
	import com.liangzhong.model.winebar.WineBarDataManager;
	import com.liangzhong.model.youngTrain.YoungTrainDataManager;
	
	import flash.utils.getTimer;
	
	/**
	 * 系统数据
	 * @author lxh
	 * 
	 */	
	public class AppData
	{
		//单例
		private static var instance :AppData;
		/**
		 * IP
		 */		
		public var ip 							:String;
		/**
		 * 端口
		 */		
		public var port 						:int;
		/**
		 *球员默认头像地址 
		 */		
		public var playerDefaultImg   			:String = "http://image.app100659253.twsapp.com/pic/star/default.png";
		/**
		 *蒙板计数 
		 */		
		private var _markCount					:int = 0;
		/**
		 *是否加载完成 
		 */		
		public var isLoadComplete 				:Boolean = false;
		/**
		 *是否连接完成 
		 */		
		public var isConnect 					:Boolean = false;
		/**
		 * 用户模块信息
		 */		
		public var user 						:User;
		/**
		 *比赛信息 
		 */		
		public var matchInfo 					:MatchInfo;
		/**
		 *俱乐部 
		 */
		private var _clubDataManager			:ClubDataManager;
		/**
		 *交易中心 
		 */		
		private var _tradeCenterManager		:TradeCenterManager;
		/**
		 *商城数据管理器 
		 */
		private var _shopDataManager			:ShopDataManager;
		/**
		 * 背包数据管理器 
		 */
		private var _bagDataManager			:BagDataManager;
		/**
		 *任务管理 
		 */		
		public var taskManager 					:TaskManager;
		/**
		 *好友管理 
		 */		
		public var friendManager 				:FriendManager;
		/**
		 *引导管理 
		 */		
		private var mGuideManager 				:GuideManager;
		/**
		 *比赛数据管理 
		 */		
		public var matchDataManager 			:MatchDataManager;
		/**
		 *邮件数据管理器 
		 */
		private var _mailDataManager			:MailDataManager;
		/**
		 *抽奖 
		 */		
		private var _lotteryDataManger			:LotteryDataManger;
		/**
		 * 巡回赛管理
		 */		
		private var mTourMatchDataManager 		:TourMatchManager;
		/**
		 *教程 
		 */		
		private var _helperDateManager			:HelperDateManger;
		/**
		 *物品管理 
		 */		
		public var goodsManager					:GoodsManager;
		/**
		 *buffer 管理 
		 */		
		public var bufferManager				:BufferManager;
		/**
		 *球员中心 
		 */
		private var _playerCenterDataManager	:PlayerCenterDataManager;
		/**
		 *训练营 
		 */
		private var _trainingCampDataManager:TrainingcampDataManager;
		/**
		 *酒吧管理 
		 */		
		public var winebarManager				:WineBarDataManager;
		/**
		 *青训营 
		 */		
		public var youngTrainManager			:YoungTrainDataManager;
		/**
		 *科技馆 
		 */		
		public var techBarManager				:TechBarDataManager;
		/**
		 *联赛 
		 */		
		public var leagueMatchManager			:LeagueMatchDataManager;
		/**
		 *npc 信息管理 
		 */		
		public var npcClubManager				:NpcClubDataManager;
		/**
		 *比赛数据管理 
		 */		
		public var stadiumDataManager			:StadiumDataManager;
		/**
		 *聊天 
		 */
		public var _chatDataManger:ChatDataManger;
		/**
		 *球场 
		 */
		public var _courtDataManager:CourtDataManager;
		/**
		 *探索 
		 */
		private var _exploreDataManager:ExploreDataManager;
		/**
		 *天梯 
		 */
		private var _ladderDataManger:LadderMatchDataManger;
		/**
		 *国家对抗赛  
		 */
		private var _competeDataManager:CompeteDataManager;
		
		/**
		 *活动 
		 */
		private var _activityDatemanager:ActivityDateManager;
		/**
		 *排行榜 
		 */
		private var _rankingListDateManager:RankinglistDataManager;
		
		/**
		 *荣誉堂  
		 */
		private var _fameHall:FameHallDateManager;
		/**
		 *黄金12宫 
		 */		
		private var _goldPalaceManager :GoldPalaceDataManager;
		/**
		 *服务器时间 
		 */
		public var serverTime:Number;
		/**
		 *客户端时间 
		 */
		private var _clientDate:Date;
		/**
		 *服务器返回的时间  S
		 */		
		private var _tempTime:Number;
		
		
		public function AppData(inner:inInnerClass)
		{
			_clientDate = new Date();
			user = new User();
			matchInfo = new MatchInfo();
			taskManager = new TaskManager();
			matchDataManager = new MatchDataManager();
			friendManager = new FriendManager();
			goodsManager = new GoodsManager();
			bufferManager = new BufferManager();
			winebarManager = new WineBarDataManager();
			youngTrainManager = new YoungTrainDataManager();
			techBarManager = new TechBarDataManager();
			leagueMatchManager = new LeagueMatchDataManager();
			npcClubManager = new NpcClubDataManager();
			stadiumDataManager = new StadiumDataManager();
		}
		/**
		 *获取实例 
		 * @return 
		 * 
		 */		
		public static function getInstance():AppData
		{
			if(instance==null)
			{
				instance = new AppData(new inInnerClass());
			}
			return instance;
		}
		/**
		 *获取黄金12宫管理器 
		 * @return 
		 * 
		 */		
		public function get goldPalaceManager():GoldPalaceDataManager
		{
			if(_goldPalaceManager == null)
			{
				_goldPalaceManager = new GoldPalaceDataManager();
			}
			return _goldPalaceManager;
		}
		/**
		 *俱乐部 
		 * @return 
		 * 
		 */		
		public function get clubDatamanager():ClubDataManager
		{
			if(_clubDataManager == null)
				_clubDataManager =new ClubDataManager();
			return _clubDataManager;
		}
		/**
		 * 交易中心 
		 * @return 
		 * 
		 */
		public function get tradeCenterManager():TradeCenterManager
		{
			if(_tradeCenterManager == null)_tradeCenterManager = new TradeCenterManager();
			return _tradeCenterManager;
		}
		
		
		/**
		 * 商城 
		 * @return 
		 * 
		 */
		public function get shopDataManager():ShopDataManager
		{
			if(_shopDataManager == null)_shopDataManager = new ShopDataManager();
			return _shopDataManager;
		}
		/**
		 *背包  
		 * @return 
		 * 
		 */
		public function get bagDataManager():BagDataManager
		{
			if(_bagDataManager == null)_bagDataManager = new BagDataManager();
			return _bagDataManager;
		}
		/**
		 *邮件 
		 * @return 
		 * 
		 */
		public function get mailDataManager():MailDataManager
		{
			if(_mailDataManager == null)_mailDataManager = new MailDataManager();
			return _mailDataManager;
		}
		/**
		 *聊天 
		 * @return 
		 * 
		 */
		public function get chatDataManager():ChatDataManger
		{
			if(_chatDataManger == null)_chatDataManger = new ChatDataManger();
			return _chatDataManger;
		}
		/**
		 *引导管理 
		 * @return 
		 * 
		 */		
		public function get guideManager():GuideManager
		{
			if(mGuideManager == null)
			{
				mGuideManager = new GuideManager();
			}
			return mGuideManager
		}
		/**
		 *巡回赛 
		 * @return 
		 * 
		 */		
		public function get tourMatchManager():TourMatchManager
		{
			if(mTourMatchDataManager == null)
			{
				mTourMatchDataManager = new TourMatchManager();
			}
			return mTourMatchDataManager;
		}
		/**
		 *球员中心 
		 * @return 
		 * 
		 */
		public function get playerCenterDataManager():PlayerCenterDataManager
		{
			if(_playerCenterDataManager == null)
				_playerCenterDataManager = new PlayerCenterDataManager();
			return _playerCenterDataManager;
		}
		/**
		 * 训练营
		 * @return 
		 * 
		 */
		public function get trainingCampDataManager():TrainingcampDataManager
		{
			if(_trainingCampDataManager == null)
				_trainingCampDataManager = new TrainingcampDataManager();
			return _trainingCampDataManager;
		}
		/**
		 *球场 
		 * @return 
		 * 
		 */
		public function get courtDataManger():CourtDataManager
		{
			if(_courtDataManager == null)_courtDataManager= new CourtDataManager;
			return _courtDataManager;
		}
		/**
		 *设置服务器时间 
		 * 
		 */
		public function setClientDate($time:Number):void
		{
			tempTime = $time;
		}
		/**
		 * 服务器时间与客户端时间差 
		 *  服务器时间 －客户端时间  
		 */
		public function get tempTime():Number
		{
			return _tempTime;
		}
		
		/**
		 * @private
		 */
		public function set tempTime(value:Number):void
		{
			_tempTime = value;
		}
		/**
		 *客户端时间 
		 * @return 
		 * 
		 */
		public function get clientDate():Date
		{
			return _clientDate;
		}
		/**
		 *获取时间（S） 服务返回的时间加上客户端(avm2)经过的时间 
		 * @return 
		 * 
		 */		
		public function get time():Number
		{
			return tempTime + int(getTimer() / 1000);
		}
		/**
		 * 服务器小时 
		 * @return 
		 * 
		 */
		public function get clientHourse():int
		{
			var date:Date = new Date(time * 1000);
			var hourse:int = date.hours;
			date = null;
			return hourse;
		}
		/**
		 * 获取客户端当前时间
		 * @return 
		 */		
		public function get curDate():Date
		{
			return new Date(time * 1000);
		}
		/**
		 * 抽奖排名管理器 
		 */
		public function get lotteryDataManger():LotteryDataManger
		{
			if(_lotteryDataManger == null)_lotteryDataManger = new LotteryDataManger();
			return _lotteryDataManger;
		}
		/**
		 *设置请求遮罩数 
		 * @param value
		 * 
		 */		
		public function set markCount(value :int):void
		{
			_markCount = value;
		}
		/**
		 * 获取请求遮罩数 
		 * @return 
		 * 
		 */		
		public function get markCount():int
		{
			return _markCount;
		}

		/**
		 * 助手管理 
		 */
		public function get helperDateManager():HelperDateManger
		{
			if(_helperDateManager == null)
			{
				_helperDateManager = new HelperDateManger();
				_helperDateManager.analysisDate();
			}
			return _helperDateManager;
		}

		/**
		 *探索 
		 */
		public function get exploreDataManager():ExploreDataManager
		{
			if(_exploreDataManager == null)_exploreDataManager = new ExploreDataManager();
			return _exploreDataManager;
		}

		/**
		 *天梯  
		 * @return 
		 * 
		 */
		public function get ladderDataManger():LadderMatchDataManger
		{
			if(_ladderDataManger == null) _ladderDataManger = new LadderMatchDataManger();
			return _ladderDataManger;
		}

		/**
		 *国家对抗赛  
		 */
		public function get competeDataManager():CompeteDataManager
		{
			if(_competeDataManager == null)_competeDataManager = new CompeteDataManager();
			return _competeDataManager;
		}
		/**
		 *活动 
		 * @return 
		 * 
		 */		
		public function get activityDatemanager():ActivityDateManager
		{
			if(_activityDatemanager == null) _activityDatemanager = new ActivityDateManager();
			return _activityDatemanager;
		}
		/**
		 *排行榜 
		 * @return 
		 * 
		 */
		public function get rankingListDateManager():RankinglistDataManager
		{
			if(_rankingListDateManager== null)_rankingListDateManager = new RankinglistDataManager();
			return _rankingListDateManager;
		}
		/**
		 *荣誉堂  
		 * @return 
		 * 
		 */
		public function get fameHallDateManager():FameHallDateManager
		{
			if(_fameHall == null)_fameHall = new FameHallDateManager();
			return _fameHall;
		}

	}
}
class inInnerClass
{
	
}